import api from "../util/api";

export const USER = "user";
export const USER_INIT = USER + "/init";

export default {
  namespace: USER,
  state: [],
  reducers: {
    setState: (_, {data}) => data
  },
  effects: {
    *init(params, { call, put }) {
      let result = yield call(api, "/api/user");
      yield put({
        type: "setState",
        data: result
      });
    }
  }
}